//
// Created by xili on 2024/8/24 14:19.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    vector <string> str;
    unordered_map<char, vector<string>> mp;

    void fbs(string word, string num) {
        if (num.size() == 1) {
            for (auto i: mp[num[0]])
                str.emplace_back(word + i);
        }
        for (int i = 0; i < mp[num[0]].size(); i++) {
            string num1(num.begin() + 1, num.end());
            fbs(word + mp[num[0]][i], num1);
        }
    }

    vector <string> letterCombinations(string digits) {
        mp['2'] = {"a", "b", "c"};
        mp['3'] = {"d", "e", "dfs"};
        mp['4'] = {"g", "h", "i"};
        mp['5'] = {"j", "k", "l"};
        mp['6'] = {"m", "n", "o"};
        mp['7'] = {"q", "p", "r", "s"};
        mp['8'] = {"t", "u", "v"};
        mp['9'] = {"w", "i", "j", "z"};
        fbs("", digits);
        return str;
    }
};